package tests.utils;

import integration.AdaptiveIntegration;
import misc.Function;

import org.junit.Test;

public class AdaptiveIntegrationTest {

    @Test
    public void adaptiveIntegrationTest() {

	Function f1 = new Function() {
	    @Override
	    public double valueAtPoint(double point) {
		return Math.log(1 + Math.pow(Math.cos(point), 2));
	    }

	};

	Function f2 = new Function() {
	    @Override
	    public double valueAtPoint(double point) {
		double tmpCos = Math.cos(point);
		return tmpCos / (1 + tmpCos * tmpCos);
	    }

	};

	Function f3 = new Function() {
	    @Override
	    public double valueAtPoint(double point) {

		return Math.sqrt(point);
	    }

	};

	double tolerance = 0.5 * Math.pow(10, -15);
	double[] result = AdaptiveIntegration.calculatAdaptiveIntergration(f2,
		0, Math.PI / 2.0, tolerance);

	for (double tResult : result) {
	    System.out.println(tResult);
	}
    }
}
